package  
{
	import flash.display.MovieClip;
	import flash.events.Event;
	/**
	 * ...
	 * @author Danilo Gama
	 */
	public class Fundo extends MovieClip
	{
		var firstFundo : BackGround;
		var secondFundo : BackGround;
		
		public function Fundo() 
		{
		
		}
		
		public function setLevel(i:int) : void
		{
			switch(i)
			{
				case 1 :
					criaFundoFase1();
					break;
				case 2 :
					criaFundoFase2();
					break;
			}
		}
		
		private function criaFundoFase1()
		{
			secondFundo = new Background1();
			firstFundo = new Background1();
			
			firstFundo.x = Main.stage.stageWidth / 2;
			firstFundo.y = Main.stage.stageHeight / 2;
			Main.screen.addChild(firstFundo);
			
			secondFundo.x = Main.stage.stageWidth / 2;
			secondFundo.y = -secondFundo.height / 2;
			Main.screen.addChild(secondFundo);
		}
		private function criaFundoFase2()
		{
			secondFundo = new Background2();
			firstFundo = new Background2();
			
			firstFundo.x = Main.stage.stageWidth / 2;
			firstFundo.y = Main.stage.stageHeight / 2;
			Main.screen.addChild(firstFundo);
			
			secondFundo.x = Main.stage.stageWidth / 2;
			secondFundo.y = -secondFundo.height / 2;
			Main.screen.addChild(secondFundo);
		}
		
		public function update():void
		{
			firstFundo.y += 2;
			secondFundo.y += 2;
			
			if (firstFundo.y == firstFundo.height/2 )
			{
				secondFundo.y = -secondFundo.height/2;
			}
			if (secondFundo.y ==  secondFundo.height/2)
			{
				firstFundo.y = -firstFundo.height/2;
			}
		}
		
	}

}